#include "AppManager.h"
static const uint8_t power_bits[] = {
    0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
    0x80, 0x81, 0x81, 0x01, 0xc0, 0x81, 0x81, 0x03, 0xe0, 0x81, 0x81, 0x07,
    0xf0, 0x80, 0x01, 0x0f, 0x78, 0x80, 0x01, 0x1e, 0x38, 0x80, 0x01, 0x1c,
    0x1c, 0x80, 0x01, 0x38, 0x1c, 0x80, 0x01, 0x38, 0x0e, 0x80, 0x01, 0x70,
    0x0e, 0x80, 0x01, 0x70, 0x06, 0x80, 0x01, 0x60, 0x06, 0x80, 0x01, 0x60,
    0x06, 0x80, 0x01, 0x60, 0x06, 0x80, 0x01, 0x60, 0x06, 0x80, 0x01, 0x60,
    0x06, 0x00, 0x00, 0x60, 0x0e, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x70,
    0x1c, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x1c,
    0x78, 0x00, 0x00, 0x1e, 0xf0, 0x00, 0x00, 0x0f, 0xe0, 0x01, 0x80, 0x07,
    0xc0, 0x07, 0xe0, 0x03, 0x80, 0x1f, 0xf8, 0x01, 0x00, 0xfe, 0x7f, 0x00,
    0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00};
class AppPower : public AppBase
{
private:
    /* data */
public:
    AppPower()
    {
        name = "power";
        title = "电源";
        description = "电源选项";
        image = power_bits;
        _showInList = false;
        _reentrant = false;
    }
    void setup();
};
static AppPower app;
extern char latest_appname[];
void AppPower::setup()
{
    const menu_item menu[] = {
        {NULL, "取消"},
        {NULL, "重启"},
        {NULL, "关机"},
        {NULL, NULL},
    };
    int res = GUI::menu("电源选项", menu);
    if(res == 1)
    {
        ESP.restart();
    }
    else if(res == 2)
    {
        latest_appname[0] = 0;
        hal.powerOff();
    }
    appManager.goBack();
}
